[C#] LINQ Group By


Feb 10, 2023

In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

長的帥,連Code都是香的 - Elvis Operator ?:

長的帥,連Code都是香的 - Elvis Operator ?:

有關Android生命週期的bug

有關Android生命週期的bug

淺談二分搜尋法

淺談二分搜尋法






留言討論